package se.webbzon.boltzmann.editor.list;

import java.util.Collection;
import java.util.Comparator;

public class NullableSortedListModel<T> extends SortedListModel<T> {
	
	// Auto generated serial version UID
	private static final long serialVersionUID = 2945179101104442397L;
	
	/*============================================================
	Constructors
	============================================================*/

	/** Creates a new nullable sorted list model. **/
	public NullableSortedListModel(Class<T> clazz) {
		super(clazz);
	}
	
	/** Creates a new nullable sorted list model with a given content. **/
	public NullableSortedListModel(Class<T> clazz, Collection<T> collection) {
		super(clazz,collection);
	}
	
	/** Creates a new nullable sorted list model. **/
	public NullableSortedListModel(Class<T> clazz, Comparator<T> comparator) {
		super(clazz,comparator);
	}
	
	/** Creates a new nullable sorted list model with a given content. **/
	public NullableSortedListModel(	Class<T> clazz, Comparator<T> comparator,
									Collection<T> collection) {
		super(clazz,comparator,collection);
	}
	
	/*============================================================
	Public Methods
	============================================================*/
	
	@Override public boolean containsElement(T element) {
		if (element == null)
			return true;
		else
			return super.containsElement(element);
	}
	
	@Override public T firstElement() {
		return null;
	}
	
	@Override public T lastElement() {
		if (super.getSize() == 0)
			return null;
		else
			return super.lastElement();
	}
	
	@Override public int getSize() {
		return super.getSize()+1;
	}
	
	@Override public T getElementAt(int index) {
		if (index == 0)
			return null;
		else
			return super.getElementAt(index-1);
	}
	
	@Override public void removeElement(int index) {
		if (index > 0)
			super.removeElement(index-1);
	}

}
